/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bean.chart;

import com.bean.chart.iterfaces.AbstractChartComposite;
import com.bean.chart.iterfaces.DataSubject;
import java.awt.BorderLayout;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author Lukasz
 */
public class ChartComposite extends AbstractChartComposite implements Serializable{

    private PropertyChangeSupport propertySupport;

    public ChartComposite(){
        super();
        propertySupport = new PropertyChangeSupport(this);
        this.setLayout(new BorderLayout());
        this.add(panelChartTitle(), BorderLayout.CENTER);
        addChartLegend();
        
    }
    
    private JPanel panelChartTitle(){
        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());
        panel.add(chartTitle, BorderLayout.NORTH);
        panel.add(chart, BorderLayout.CENTER);
        panel.add(chartUnit, BorderLayout.WEST);
        return panel;
    }
    @Override
    protected void addChartLegend(){
        
        
        switch(this.getLegendPosition()){
            case DOWN:
                this.add(chartLegend, BorderLayout.SOUTH);
                break;
            case UP:
                this.add(chartLegend, BorderLayout.NORTH);
                break;
            case LEFT:
                this.add(chartLegend, BorderLayout.WEST);
                break;
            case RIGHT:
                this.add(chartLegend,BorderLayout.EAST);
                break;
            default:
                this.add(chartLegend, BorderLayout.SOUTH);
                break;
        }
        
    }
    protected JPanel unitPanel(){
        JPanel panel = new JPanel();
        panel.add(new JLabel("Sdasdasasd"));
        return panel;
    }
    @Override
    protected void propertyChange(String property, boolean oldval, boolean newVal) {
        propertySupport.firePropertyChange(property, oldval, newVal);
    }

    @Override
    protected void propertyChange(String property, String oldval, String newVal) {
        propertySupport.firePropertyChange(property, oldval, newVal);
    }

    @Override
    protected void propertyChange(String property, Object oldval, Object newVal) {
         propertySupport.firePropertyChange(property, oldval, newVal);
    }
    
}
